﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using document_manage.添加文档;
using System.Data;
using System.Data.SqlClient;

namespace document_manage.文件分类
{
    /// <summary>
    /// other.xaml 的交互逻辑
    /// </summary>
    public partial class other :Window
    {
       
        public string text = null;
        WrapPanel wp = new WrapPanel();

        Button btn = new Button();
        public other()
        {
            InitializeComponent();
   
        }
        MySQLConn con = new MySQLConn();            //连接数据库

        List<Button> lb = new List<Button>();
         List<Label > lb2 = new List<Label >();
         List<WrapPanel> lb1 = new List<WrapPanel>();
        private void button_Click_AddMenu(object sender, RoutedEventArgs e)
        {
            Add add = new Add(text);
            add.MyEvent += new MyDelegate(form2_MyEvent);
            add.Show();
        }
        void form2_MyEvent(string text)
        {

            Label label = new Label();

            label.Content = "X";
            label.MouseDown += label_MouseDown;
            btn.Content = text.ToString();
            btn.Background = Brushes.White;
            btn.Margin = new Thickness(20, 10, 0, 0);

            lb1.Add(wp);
            lb2.Add(label);

            listBox.Items.Add(wp);
            wp.Children.Add(btn);
            wp.Children.Add(label);
            lb.Add(btn);
        }

        void label_MouseDown(object sender, MouseButtonEventArgs e)
        {
           // throw new NotImplementedException();
            listBox.Items.Remove(wp);
            listBox.Items.Remove(btn);
        }


        private string label_Name;

        private void delete_Menu(object sender , MouseButtonEventArgs e)
        {
            Label label = sender as Label;
            label_Name = label.Name;

        }


        private void Label_MouseDown(object sender, MouseButtonEventArgs e)
        {
            listBox.Items.Remove(wrappanel1);
        }

        private void label2_MouseDown(object sender, MouseButtonEventArgs e)
        {
            listBox.Items.Remove(wrappanel2);
        }

        private void label3_MouseDown(object sender, MouseButtonEventArgs e)
        {
            listBox.Items.Remove(wrappanel3);
        }

        //加载数据到页面上
        private void data_Load(object sender,EventArgs e)
        {
            string sql = "select * from doc_file";
            DataTable dt = new DataTable();         //新建DataTable类存放数据库输出结果
            dt = con.ExecuteQuery(sql);
            dataGrid.ItemsSource = dt.DefaultView;  

        }//end loadData

    }

   
}

